package com.wfy.controller;

import com.wfy.entity.Response;
import com.wfy.entity.User;
import com.wfy.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping(value = "/user")
@CrossOrigin
public class UserController {

    @Autowired
    private UserService userService;


    @RequestMapping("/getAllUser")
    @ResponseBody
    private List<User> getAllUser() {
        List<User> users = userService.getAllUser();
        return users;
    }

    @PostMapping("/login")
    public Response isLogin(@RequestParam(value = "userName") String userName,
                                        @RequestParam(value = "password") String password) {
        return userService.isLogin(userName, password);
    }

    @PostMapping("/register")
    public Response exportTrustRealData(@RequestParam(value = "userName") String userName,
                                        @RequestParam(value = "password") String password) {
        return userService.register();
    }

}
